import request from '../utils/request.js'

//  通过 ip 地址查询所在城市
export const getCityByIp = () => {
    return request({
        method: 'GET',
        url: '/ip?',
        params: {
            key: '94f74f34d825c64bcfbc9a2831ba10be'
        }
    })
}

//通过城市名查询 adcode
export const getAdcodeByCity = (address) => {
    return request({
        method: 'GET',
        url: '/geocode/geo?',
        params: {
            key: '94f74f34d825c64bcfbc9a2831ba10be',
            address: address
        }
    })
}

//通过 adcode 查询城市天气
export const getWeatherByAdcode = (adcode) => {
    return request({
        method: 'GET',
        url: 'weather/weatherInfo?',
        params: {
            key: '94f74f34d825c64bcfbc9a2831ba10be',
            city: adcode
        }
    })
}

//通过 adcode 查询城市天气预报
export const getWeatherForecastByAdcode = (adcode) => {
    return request({
        method: 'GET',
        url: 'weather/weatherInfo?',
        params: {
            key: '94f74f34d825c64bcfbc9a2831ba10be',
            city: adcode,
            extensions: 'all'
        }
    })
}
